home *** CD-ROM | disk | FTP | other *** search
/ Revista CD Expert 37 / CD Expert nº 37.iso / LastCall / lastcall.exe / stuff / lastcall.dxr / 00087_Volume Slider in Juke Box.ls < prev    next >
Encoding:
Text File  |  2000-03-27  |  828 b   |  38 lines

  1. property pSpr, pMinLeft, pMaxRight
  2. global gMusicChan
  3.  
  4. on beginSprite me
  5.   pSpr = sprite(me.spriteNum)
  6.   pMinLeft = 78
  7.   pMaxRight = 152
  8.   mUpdate(me)
  9. end
  10.  
  11. on mouseDown me
  12.   repeat while the stillDown
  13.     checkElapsedTime()
  14.     pSpr.locH = min(max(pMinLeft, the mouseH), pMaxRight)
  15.     updateStage()
  16.   end repeat
  17. end
  18.  
  19. on mouseUp me
  20.   global gMuted, gJukeMuteButton
  21.   gMuted = 0
  22.   sendSprite(gJukeMuteButton, #mouseLeave)
  23.   mid = pSpr.locH - pMinLeft
  24.   percent = float(mid) / (pMaxRight - pMinLeft)
  25.   newVolume = integer(255 * percent)
  26.   set the volume of sound gMusicChan to fixVolume(newVolume)
  27.   mUpdateVolumeSlider(me)
  28. end
  29.  
  30. on mUpdate me
  31.   pSpr.locH = pMinLeft + (the volume of sound gMusicChan / 255.0 * (pMaxRight - pMinLeft))
  32. end
  33.  
  34. on mUpdateVolumeSlider me
  35.   mUpdate(me)
  36.   playBeepSound(the volume of sound gMusicChan)
  37. end
  38.